﻿using DryWCS.Model.User;
using DryWCS.Service.DbContext;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DryWCS.Service.User
{
    public class UserService : LocalDbContext<UserModel>
    {
        #region 根据用户名和密码查询用户实体
        public UserModel GetUserModelByPassword(string nikeName, string password)
        {
            try
            {
                return Db.Queryable<UserModel>().Where(it => it.Nikname == nikeName && it.Password == password).First();
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        #endregion

        #region 根据用户名称查询
        public List<UserModel> GetLUserModelByNikename(string nikename)
        {
            try
            {
                if (string.IsNullOrEmpty(nikename))
                {
                    return GetList();
                }
                else
                {
                    return Db.Queryable<UserModel>().Where(it => it.Nikname == nikename).ToList();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        #endregion
    }
}
